/*
 *  Gurr - A multiprotocol chat client for Android
 *  Copyright (C) 2011 Malte Aschermann, Wilfried Ramaker
 *  
 *  This file is part of Gurr.
 *  
 *  Gurr is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  Gurr is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *  
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Gurr.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.masc.gurr.net;

import java.util.ArrayList;
import java.util.Iterator;

public class Group {
	private String name;
	private int id;
	private ArrayList<Contact> contacts;
	private ArrayList<Group> subgroups;
	private Group parentGroupRef;
	
	public Group(String name) {
		this.name = name;
		subgroups = new ArrayList<Group>();
		contacts = new ArrayList<Contact>();
		parentGroupRef=null;
	}
	
	public Group(int id) {
		this.id = id;
		subgroups = new ArrayList<Group>();
		contacts = new ArrayList<Contact>();
		parentGroupRef=null;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Iterator<Contact> getContacts() {
		return contacts.iterator();
	}
	public void setContacts(ArrayList<Contact> contacts) {
		this.contacts = contacts;
	}
	public Iterator<Group> getSubgroups() {
		return subgroups.iterator();
	}
	public void removeSubGroup(Group subgroup) {
		subgroup.setParentGroup(null);
		this.subgroups.remove(subgroup);
	}
	public void addSubGroup(Group pSubGroup) {
		this.subgroups.add(pSubGroup);
		pSubGroup.setParentGroup(this);
	}
	public void addContact(Contact pContact) {
		this.contacts.add(pContact);
		pContact.setGroupRef(this);
	}

	public Group getParentGroup() {
		return parentGroupRef;
	}

	public void setParentGroup(Group parentGroupRef) {
		this.parentGroupRef = parentGroupRef;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	
}

